<title><?=$ltitle?></title>
<link rel="stylesheet" type="text/css" href="css/distri.css"/>
<link rel="stylesheet" type="text/css" href="css/jump.css"/>
<script type="text/javascript" src="js/jquery.getareas.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($){
    $("#area").getAreas({update:true,pro_id:<?=$prov?>,city_id:<?=$city?>,county_id:0,depth:2});
    $(".searbtn").click(function(){
        $("#act").val("");
    })
});
function setFund(id,a){
    $('#fund').show();
    $('#mask').show();
    var td=$(a).parent().parent().children();
    $("#info").html(td.eq(0).html());
    $("#tmoney").html(td.eq(3).html());
    $("#cmoney").val(td.eq(4).html());
    $("#did").val(id);
    $("#ali").val('通过支付宝');
}
function cl(c){
    if(c.value=="请输入企业名称\\账号\\手机"){
        c.value="";
        c.style.color="#000";
        return;
    }
    if(c.value==""){
        c.value="请输入企业名称\\账号\\手机";
        c.style.color="#888";
        return;
    }
}
function close(){
    $('#fund').hide();
    $('#mask').hide();
}
function chTpl(d,t){
    if(d)alert($.ajax({url:"call/setLowTpl.php",data:{did:d,tplid:t},async:false}).responseText);
}
function paytype(t){
    if(!$('#money').val()){
        alert('请填写金额');
        return false;
    }
    var b=$('#ali');
    var f=document.forms['pay'];
    if(t==1){
        if(b.val()=="完成/重新支付"){
            window.location.reload();
            return false;
        }
        else{
            b.val("完成/重新支付");
        }
        f.target='_blank';
        f.action='recharge.php';
    }
    else if(t==0){
        f.target='ifr';
        f.action='call/setFund_n.php';
    }
    f.submit();
}
function break_off(id,dtype){
    if(confirm('若想重新建立合作关系，可到\"添加分销商\"页面。确定删除？')){
        //alert(id+'|'+dtype);
        $.getJSON("call/chRela.php", { dtype:dtype, id:id}, function(json){
            //alert(json['id']+'|'+json['dtype']+'|'+json['parent_id']+'|'+json['sessionmemberID']+'|'+json['son_id']);
            if(json['status']!='ok'){alert(json['msg']);}
            else{alert('删除成功!');window.location.reload();}
        });
    }
}
function transfer(id,a){
    $('#fund').show();
    $('#mask').show();
    var td=$(a).parent().parent().children();
    $("#info").html(td.eq(0).html());
    $("#tmoney").html(td.eq(3).html());
    $("#did").val(id);
    $("#act").val("z");
}
</script>
<style type="text/css">
.fund{display:none;background:white; left:50%; margin-left:-195px; margin-top:-100px; position:absolute; top:50%; width:390px; height:300px; padding:5px 20px 15px; z-index:100;}
.fund table{ margin-top:0px;}
.fund table thead th{text-align:left; padding:0 7px; height:40px; line-height:40px; border-bottom:2px solid #999; font-weight: bold; font-size:14px;}
.fund table thead{ background-color:transparent; height:auto; border:0;}
.fund table thead th span{ cursor:pointer; display:inline-block; float:right; width:17px; height:17px; background:url(images/close.png) no-repeat; margin-top:12px;}
.fund table td{ height:auto; padding:15px; text-align:left;}
.fund table td p{font-weight:bold; text-align:left;height:30px; line-height:30px;}
.fund table td p font{margin:0 5px;}
.fund table td span{line-height:30px;}
.fund table td span.yuck{display:inline-block;width:69px;height:40px;line-height:40px;}
#money_u{ height:18px; line-height:18px; padding:2px 4px; border:1px solid #CCCCCC; width:60px; margin:12px 4px 0;}
#money{ height:18px; line-height:18px; padding:2px 4px; border:1px solid #CCCCCC; width:100px;}
#bei{ resize: none;height:60px; line-height:18px; padding:2px 4px; border:1px solid #CCCCCC; width:200px;}
.fund table td span.qd input{ background:url(images/btn23bg2.png) repeat-x; border:1px solid #FF8000; border-bottom-color:#F55C00; height:25px;  line-height:23px; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; color:#FFF; font-weight:bold; margin:15px 0 0 55px; *margin-left:10px; padding:0 10px;}
.fund table td span.qd input:hover{ background:url(images/btn23bg22.png) repeat-x;}
.mc_title a{float:right; margin-right:50px; line-height:25px;}
.dismtab thead th.txtlf{ text-align:left; padding-left:8px;}
.dismtab tbody td.txtlf{ text-align:left; padding-left:8px;}
#excel{width:80px;height:30px;float:right;border:none;background:#00AAD3;cursor:pointer;color:#FFF;}
#excel:hover{background:#03A2C9;}
</style>
<iframe name="ifr" style="display:none;"></iframe>
<div class="r_content">
    <h3 class="mc_title">
    <?if($dtype==0){?><a target="_blank" href="tpllist.html">模板管理</a><a href="distributor_add.html" target="_blank" style="background:url(images/img_add.gif) left center no-repeat; padding-left:20px; margin-right:10px;">添加分销商</a><?}?>
        <span class="mctit_1"><span class="mctit_2"><?=$ltitle?></span></span>
    </h3>
    <div class="dissear_box">
        <form id="search">
            <input type="hidden" name="dtype" value="<?=$_REQUEST['dtype']?>"/>
            <input type="hidden" name="act" id="act" />
           
           
           
            <p>
                <b>搜索条件：</b><span><input type="text" class="sertxt" name="txt" onfocus="cl(this)" onblur="cl(this)" value="<?=$txt?>" /></span>
            <?    if($dtype==7){?>
                <b>成员类型：</b>
                <span><select name="_dtype" id=""><option value="0,3">全部</option><option <?if($_dtype=="3")echo "selected";?> value="3">供应商</option><option <?if($_dtype=="0")echo "selected";?> value="0">分销商</option></select></span>
            <?    }else{?>
                <b>区域搜索：</b>
                <span id="area">
                </span>
            <?    }?>
            </p>
        <?if($dtype==0){  $ctype = is_array($ctype)? $ctype:array(); ?>
            <p>
                <b>分销商类型：</b>
                <span>
                    <label><input type="checkbox" class="chek" <?if(in_array("",$ctype)&&(sizeof($ctype)==1))echo "checked";?> name="com_type[]" value="" />全部</label>
                    <label><input type="checkbox" class="chek" <?if(in_array("旅行社",$ctype))echo "checked";?> name="com_type[]" value="旅行社" />旅行社</label>
                    <label><input type="checkbox" class="chek" <?if(in_array("加盟门店",$ctype))echo "checked";?> name="com_type[]" value="加盟门店" />加盟门店</label>
                    <label><input type="checkbox" class="chek" <?if(in_array("电商",$ctype))echo "checked";?> name="com_type[]" value="电商" />电商</label>
                    <label><input type="checkbox" class="chek" <?if(in_array("团购网",$ctype))echo "checked";?> name="com_type[]" value="团购网" />团购网</label>
                    <label><input type="checkbox" class="chek" <?if(in_array("淘宝/天猫",$ctype))echo "checked";?> name="com_type[]" value="淘宝/天猫" />淘宝/天猫</label>
                    <label><input type="checkbox" class="chek" <?if(in_array("其他",$ctype))echo "checked";?> name="com_type[]" value="其他" />其他</label>
                </span>
            </p>
        <?}?>
        <p>
            <span><input type="button" id="excel" class="btn" value="导出"/></span>
            <span class="fltrig"><input type="submit" class="searbtn" value="查询"/></span>
        </p>
        </form>
    </div>
    <div id="fund" class="fund">
        <table class="dismtab">
            <thead>
                <th><span onclick="$('#fund').hide();$('#mask').hide();"></span><?if($dtype==7){echo "线下充值";}else{echo "分销还款/充值";}?> - <font id="info" color="green"></font></th>
            </thead>
            <tbody>
                <tr>
                    <td>
                      <form name="pay" action="call/setFund_n.php" target="ifr">
                      <!-- <form name="pay" action="admin/pppp.php" target="ifr">  -->
                        <input type="hidden" name="did" id="did" />
                    <?    if($dtype==7){?>
                        <input type="hidden" name="act" id="act" value="z" />
                        <span class="yuck">线下充值其资金账户<input type="text" name="tmoney" id="money" />元</span><br />
                        <span class="qd"><input type="button" onclick="paytype(2)" value="确 认 充 值" /></span>
                        <span class="qd"><input type="button" onclick="$('#fund').hide();$('#mask').hide();" value=" 取 消 " /></span>
                    <?    }else{?>
                        <input type="hidden" name="act" id="act" value="r" />
                        <p>当前供应账户余额<font id="tmoney" color="green"></font>元</p>
                        <span class="yuck">预存/还款：</span><input type="text" name="money" id="money" />&nbsp;&nbsp;元<br />
                        <span class="yuck">备注：</span><textarea name="memo" id="bei" maxlength="200" ></textarea>&nbsp;&nbsp;元<br />
                        <span class="qd"><input type="button" onclick="paytype(0)" value="使用账户余额" /></span>
						<span class="qd"><input type="button" id="ali" onclick="paytype(1)" value="通过支付宝" /></span>
                    <?    }?>
                        <!-- <br />
                        <span>&nbsp;&nbsp;允许预支最多<input type="text" name="cmoney" id="cmoney" />元</span>
                        <span class="qd"><input type="submit" onclick="$('#act').val('c')" value=" 修 改 " /></span> -->
                      </form>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <table class="dismtab aa">
        <thead>
            <th class="txtlf">企业名称（账号）</th>
            <th class="txtlf w100">联系人</th>
            <th class="w100">手机号码</th>
        <?if($dtype==7):?>
            <th>资金余额</th>
        <?else:?>
            <?php if($_SESSION['sid']!=55):?>
            <th class="w100" title="供应商余额=账户余额+授信额度">当前可用余额</th>
            <?php endif;?>
            <?if($dtype==0):?>
            <th class="w100">价格模板</th>
            <?endif;?>
        <?endif;?>
            <th class="w130">操作</th>
        </thead>
        <tbody>
        <?foreach($a_sort as $v):?>
            <tr>
                <td class="txtlf"><a target="_blank" href="userinfo.html?id=<?=$v['id']?>"><?=$v['dname']?>（ID:<?=$v['account']?>）</a></td>
                <td class="txtlf"><?=$v['cname']?></td>
                <td><?=$v['mobile']?></td>
                <?if($dtype==7):?>
                    <td><?=(float)$a[$v['id']]?></td>
                    <td class="">
                    <?if($v['son_id_type']==0):?>
                        --<!-- <a href="javascript:void(0)" onclick="setFund(<?=$v['id']?>,this)">充值</a> -->
                    <? else:?>
                        --
                    <? endif;?>
                <?else:?>
                        <?php if($_SESSION['sid']!=55):?>

                <td title="供应商余额=账户余额(<?=$a[$v['id']]?>)+授信额度(<?=$b[$v['id']]?>)"><?=(float)($a[$v['id']]+$b[$v['id']])?></td>
                        <?php endif;?>
                <?if($dtype==0):?>
                <td>
                    <select onchange="chTpl(<?=$v['id']?>,this.value)" style="width: 80px">
                        <option value="">未套用</option>
                    <?foreach($tpl as $t):?>
                        <option <?if($_tpl[$v['id']]==$t['id'])echo "selected";?> value="<?=$t['id']?>" ><?=$t['title']?></option>
                    <?endforeach;?>
                    </select>
                </td>
                <td class="tdrig">
                    <a href="priceset.html?did=<?=$v['id']?>">价格配置</a>
					<!--<a href="repayment.html?id=<?=$v['id']?>">授信/预存</a>-->
                    <!--<a target="_blank" href="credit_.html?did=<?=$v['id']?>" >授信/预存</a>-->
                    <a target="_blank" href="repayment.html?did=<?=$v['id']?>" >授信/预存</a>
                    <br/>
                    <a target="_blank" href="wx_shop_qr.html?id=<?=$v['id']?>">微信分店二维码</a>
                <? else :?>
                <td class="tdrig">
                    <!--<a href="javascript:void(0)" onclick="setFund(<?=$v['id']?>,this)">预存/还款</a>-->
                    <!--<a target="_blank" href="credit_.html?aid=<?=$v['id']?>">预存/还款</a>-->
                    <a target="_blank" href="repayment.html?aid=<?=$v['id']?>">预存/还款</a>
                <? endif;?>
                    <a href="javascript:void(0);" onclick="break_off(<?=$v['id']?>,<?=$dtype?>)">删除</a>
            <?endif;?>
                </td>
            </tr>
        <? endforeach;?>
            <?if($dtype==7):?>
            <tr>
                <td style="text-align:right;color:red;" colspan="3">合计：</td>
                <td><?=(float)$count?></td>
                <td><a href="rrecord.html">记录</a></td>
            </tr>
            <?php endif;?>
        </tbody>
    </table>
    <?page($total,$currentPage,$pageSize);?>
</div>
<script>
$(function(){
    $("#excel").click(function(){
        $("#act").val("loadExcel");
        $("#search").submit();
    });
});
</script>